function
	local taskname="userDataTask"
	log.info(taskname,"start")
	local nid,netr,nets=1,"",""
	local uid,uartr,uarts=1,"",""
	local oldkey,oldkey2 =nil,nil
	local in1os,in2os,in3os,in4os=nil,nil,nil,nil
	local needup=1
	local lastuptime=0

	PronetStopProRecCh(1)
	UartStopProRecCh(1) --如果串口数据还需要透传，需要删除
	PerSetDo(1,0)
	PerSetDo(2,0)

	local cmd = {
		{0xff,0xaa,0x08,0x7D,0x01,0xCC,0xFF,0xFF,0xFF,0x01,0x01,0x51}, --1 on
		{0xff,0xaa,0x08,0x7D,0x01,0xCC,0xFF,0xFF,0xFF,0x01,0x00,0x50},-- 1 off
		{0xff,0xaa,0x08,0x7D,0x01,0xCC,0xFF,0xFF,0xFF,0x02,0x01,0x52},-- 2 on
		{0xff,0xaa,0x08,0x7D,0x01,0xCC,0xFF,0xFF,0xFF,0x02,0x00,0x51} -- 2 off
	}

	local cmdBackHex = {0xff,0xaa,0x07,0x7D,0x01,0xCC,0xFF,0xFF,0xFF,0x00,0x4E}
	local cmdBackHexStr = ToolTableToHexStr(cmdBackHex)

	-- 比较两个数组是否相等
	function compareArrays(t1, t2)
		-- 如果长度不相等，返回false
		if #t1 ~= #t2 then
			return false
		end
		-- 比较每个对应的元素
		for i = 1, #t1 do
			if t1[i] ~= t2[i] then
				return false
			end
		end
		-- 如果所有元素都相等，返回true
		return true
	end

	while true do
	    --解析网络数据
		netr = PronetGetRecChAndDel(nid)
		if netr then
			log.info(taskname,"netr data",netr)
			local hexStr = netr
			if hexStr and type(hexStr) == 'string' then
				local hexTable = ToolHexStrToTable(hexStr)
				if compareArrays(hexTable,cmd[1]) then
					PerSetDo(1,1)
				elseif compareArrays(hexTable,cmd[2]) then
					PerSetDo(1,0)
				elseif compareArrays(hexTable,cmd[3]) then
					PerSetDo(2,1)
				elseif compareArrays(hexTable,cmd[4]) then
					PerSetDo(2,0)
				end
				if 1==PronetGetNetSta(nid) then
					PronetSetSendCh(nid,cmdBackHexStr)
				end
			end
		end

        -- --检查输入通道1是否变化控制继电器
		local key=PerGetDiById(1)
		if oldkey~=key then
			oldkey=key
			if key==0 then
				local s = PerGetDoSta(1)
				if s ==0 then
					PerSetDo(1,1)
				else
					PerSetDo(1,0)
				end
			end
		end

		-- --检查输入通道2是否变化控制继电器
		local key2=PerGetDiById(2)
		if oldkey2~=key2 then
			oldkey2=key2
			if key2==0 then
				local s2 = PerGetDoSta(2)
				if s2 ==0 then
					PerSetDo(2,1)
				else
					PerSetDo(2,0)
				end
			end
		end

		--周期上报设备状态
		local nowtime = os.time()
		if nowtime-lastuptime > 60 then
			lastuptime = nowtime
			needup=1
		end

		--检查继电器状态变化马上上报
		local d ={}
		local in1s=PerGetDoSta(1)
		local in2s =PerGetDoSta(2)

		-- d.datetime=os.date("%Y-%m-%d %H:%M:%S")
		-- d.csq=mobile.csq()
		-- d.imei=mobile.imei()
		-- d.iccid = PerGetIccid()
		-- d.vbat = PerGetVbattV()
		d.In1 = in1s
		d.In2 = in2s

		if in1s~=in1os then
			in1os =in1s
			needup=1
		end
		if in2s~=in2os then
			in2os =in2s
			needup=1
		end

		-- 状态映射表
		local status = {
			{0xff,0xaa,0x08,0x7D,0x02,0xCC,0xFF,0xFF,0xFF,0x00,0x00,0x50}, --1 off 2 off
			{0xff,0xaa,0x08,0x7D,0x02,0xCC,0xFF,0xFF,0xFF,0x01,0x00,0x51},-- 1on 2 off
			{0xff,0xaa,0x08,0x7D,0x02,0xCC,0xFF,0xFF,0xFF,0x01,0x01,0x52},-- 1 on 2 on
			{0xff,0xaa,0x08,0x7D,0x02,0xCC,0xFF,0xFF,0xFF,0x00,0x01,0x51} --1 on 2 off
		}


		if needup ==1 then
			-- 根据 d.In1 和 d.In2 的值选择对应的状态
			local selectedStatus
			if d.In1 == 0 and d.In2 == 0 then
				selectedStatus = status[1]  -- 1 off, 2 off
			elseif d.In1 == 1 and d.In2 == 0 then
				selectedStatus = status[2]  -- 1 on, 2 off
			elseif d.In1 == 1 and d.In2 == 1 then
				selectedStatus = status[3]  -- 1 on, 2 on
			elseif d.In1 == 0 and d.In2 == 1 then
				selectedStatus = status[4]  -- 1 off, 2 on
			else
				-- 如果 d.In1 和 d.In2 的值不在上述范围内，可以设置默认值或返回错误
				selectedStatus = nil
				log.error("Invalid input state")
			end

			netsta = PronetGetNetSta(nid)
			log.info(taskname,"status",selectedStatus,"netsta",netsta)
			if selectedStatus and netsta ==1 then
				local statusStr = ToolTableToHexStr(selectedStatus)
				PronetSetSendCh(nid,statusStr)
			end
			needup=0
		end
		sys.wait(100)
	end
end